<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/jsp/admintop.jsp" %>
<%@ taglib uri="/FCKEdit" prefix="fck"%>
<%@ include file="/jsp/jscommom.jsp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>添加企业</title>
<link href="/css/login.css" rel="stylesheet" type="text/css" />
</head>
<script type="text/javascript" src="/js/prototype-1.5.1.2.js"
		charset="UTF-8"></script>
<script language="javascript">
<bean:write name="com_struts_web_corpor_manage_infomanage_EditInfoForm" property="printVacaSql" filter="false"/>
<bean:write name="com_struts_web_corpor_manage_infomanage_EditInfoForm" property="printAddressSql" filter="false"/>
<bean:write name="com_struts_web_corpor_manage_infomanage_EditInfoForm" property="printKindSql" filter="false"/>

//定义一个变量用于存放XMLHttpRequest对象
	var xmlHttp; 
	
	//该函数用于创建一个XMLHttpRequest对象
	function createXMLHttpRequest() {
		if (window.ActiveXObject) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		else if (window.XMLHttpRequest) {
			xmlHttp = new XMLHttpRequest();
		}
	}


//检查用户名是否存在
function checkLoginName(){
        var lname = document.all.loginName.value;
        if(lname=="" || lname.length<0){
        alert("\u5bf9\u4e0d\u8d77\uff0c\u7528\u6237\u540d\u4e0d\u80fd\u4e3a\u7a7a\uff01");
        document.all.loginName.value="";
        document.all.loginName.focus();
        }else{
    	var url = '/com/checkcorloginname.do';
        var pars = 'lname='+lname;
     
        var myAjax = new Ajax.Updater({success:'checkloginname'}, url, {method: 'get', parameters: pars});
        }
    	}
	
	//这是响应列表的onChange事件的处理方法
	function updateSelect(){
		var selected = document.all.stations.value;//得到省份列表的当前选值
		//创建一个XMLHttpRequest对象
		createXMLHttpRequest();
		//将状态触发器绑定到一个函数
		xmlHttp.onreadystatechange = processor;
		//通过GET方法向指定的URL建立服务器的调用
		xmlHttp.open("GET", "SubStationXML?selected="+selected);
		//发送请求
		xmlHttp.send(null);
	}
	
	//处理从服务器返回的XML文档并更新列表
	function processor() {
		//定义一个变量用于存放从服务器返回的响应结果
		var result;
		if(xmlHttp.readyState == 4) { //如果响应完成
			if(xmlHttp.status == 200) {//如果返回成功
				//取出服务器返回的XML文档的所有标签的子节点
				result = xmlHttp.responseXML.getElementsByTagName("substation");
				//先清除列表的现有内容
				while (document.all.subStation.options.length>0){
					document.all.subStation.removeChild(document.all.subStation.childNodes[0]);
				}
				//解析XML中的数据并更新
				for(var i=0;i<result.length;i++){
					var option = document.createElement("OPTION");
					option.text = result[i].childNodes[0].childNodes[0].nodeValue;//这就是取出值
					option.value = result[i].childNodes[1].childNodes[0].nodeValue;//这就是取出值
					
					document.all.subStation.options.add(option);//为岗位列表添加
				}
			}
		}
	}
	
	function doedit(){
	
	  
	
	   if(document.all.contactPerson.value==""){
	      alert("对不起,联系人不能为空!");
	      return;
	   }
	   if(document.all.mobilphone.value==""){
	      alert("对不起,手机号码不能为空!");
	      return;
	   }
	   if(document.all.email.value==""){
	      alert("对不起,电子邮箱不能为空!");
	      return;
	   }
	   if(document.all.createDate.value==""){
	      alert("对不起,企业成立日期不能为空!");
	      return;
	   }
	   var fckconfig = document.getElementById("corporContent");
var str=FCKeditorAPI.GetInstance('corporContent').GetXHTML(fckconfig.FormatOutput);

    if(str==""){
    alert("对不起,企业简介不能为空!");
    return false;
    }
    
	   document.all.method.value="add";
	   document.forms[0].submit();
	   document.all.method.value="";
	
	}
	
	//检查密码
 function checkPwd(){
		if (document.all.passWord.value != document.all.repassword.value){
			alert('\u5bf9\u4e0d\u8d77\uff0c\u4e24\u6b21\u8f93\u5165\u7684\u5bc6\u7801\u4e0d\u4e00\u81f4\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165\uff01');
			document.all.passWord.value = "";
			document.all.repassword.value ="";
			document.all.passWord.focus();
		}
	}
</script>
<body>
<html:form action="/com/struts/system/addcorpor" method="post">
<html:hidden property="method"/>
  <div align="center">
  <nested:nest property="corporPo">
    <table width="880" border="0" align="center" cellpadding="0"
					cellspacing="1" class="line1">
    
    
    <tr>
    
    
    <td class="titlebg" colspan="4">
    添加企业
    </td>
    </tr>
    
    <tr>
    <td class="mtdtitle1">
    *账号:
    </td>
    <td class="mtdtextleft">
    <nested:text property="loginName" styleId="loginName" onblur="checkLoginName()"/>
    <font color="red"><div id="checkloginname"></div></font>
    </td>
    <td class="mtdtitle1">
    *企业名称:
    </td>
    <td class="mtdtextleft">
    <nested:text property="corporationName"/>
    </td>
    </tr>
    
    <tr>
    <td class="mtdtitle1">
    *密码:
    </td>
    <td class="mtdtextleft">
    <nested:password property="passWord" styleId="passWord"/>
    </td>
    <td class="mtdtitle1">
    *确认密码:
    </td>
    <td class="mtdtextleft">
	<input type="password" onblur="checkPwd()" id="repassword" class="input1"/>
	</td>
    </tr>
    
    <tr>
    <td class="mtdtitle1">
    *所属行业:
    </td>
    <td class="mtdtextleft">
    <nested:select property="vocationId" styleId="vocationId">
    <SCRIPT language=JavaScript>
			        for (var i = 0; i < (vocation.length); i++) {
			         document.write("<OPTION value='"+vocation[i]+"' ");
			    document.write(">" + vocation[++i]+"</OPTION>");
			  }
			</SCRIPT>
    </nested:select>
    </td>
    <td class="mtdtitle1">
    *企业性质:
    </td>
    <td class="mtdtextleft">
    <nested:select property="kindId" styleId="kindId">
    <SCRIPT language=JavaScript>
			        for (var i = 0; i < (kindId.length); i++) {
			         document.write("<OPTION value='"+kindId[i]+"' ");
			    document.write(">" + kindId[++i]+"</OPTION>");
			  }
			</SCRIPT>
    </nested:select>
    </tr>
    
    <tr>
    <td class="mtdtitle1">
    *所在地区:
    </td>
    <td class="mtdtextleft" colspan="3">
    <nested:select property="address" styleId="address" >
    <SCRIPT language=JavaScript>
			        for (var i = 0; i < (address.length); i++) {
			         document.write("<OPTION value='"+address[i]+"' ");
			    document.write(">" + address[++i]+"</OPTION>");	
			  }
			</SCRIPT>
    </nested:select>
    </td>
    </tr>
    
    <tr>
    <td class="mtdtitle1">
    *成立日期:
    </td>
    <td class="mtdtextleft">
    <nested:text property="createDate" styleId="createDate" onclick="datepopup(this);" />
    </td>
    <td class="mtdtitle1">
    公司主页:
    </td>
    <td class="mtdtextleft">
    <nested:text property="homepage" styleId="homepage"></nested:text>
    </td>
    </tr>
    
    <tr>
    <td colspan="4" class="mtdtitle1">
    联系方式：
    </td>
    </tr>
    
    <tr>
    <td class="mtdtitle1">
    *联系人:
    </td>
    <td class="mtdtextleft">
    <nested:text property="contactPerson" styleId="contactPerson"></nested:text>
    </td>
    <td class="mtdtitle1">
    *电话号码:
    </td>
    <td class="mtdtextleft">
    <nested:text property="telephone"/>
    </td>
    </tr>
    
    <tr>
    <td class="mtdtitle1">
    *手机号码:
    </td>
    <td class="mtdtextleft">
    <nested:text property="mobilphone" styleId="mobilphone"></nested:text>
    </td>
    
    <td class="mtdtitle1">
    *邮箱:
    </td>
    <td class="mtdtextleft">
    <nested:text property="email" styleId="email"></nested:text>
    </td>
    </tr>
    
    <tr>
    <td class="mtdtitle1">
    *联系地址:
    </td>
    <td class="mtdtextleft" colspan="3">
    <nested:text property="contactAddress"/>
    </td>
    </tr>
    
    <tr>
    <td class="mtdtitle1" colspan="4">
    *企业简介:
    </td>
    </tr>
    <tr>
    <td class="mtdtextleft" colspan="4" height="500">
    <fck:editor id="corporContent" basePath="/" height="100%"
								skinPath="/editor/skins/default/" toolbarSet="Default"
								imageBrowserURL="/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector"
								linkBrowserURL="/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector"
								flashBrowserURL="/editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector"
								imageUploadURL="/editor/filemanager/upload/simpleuploader?Type=Image"
								linkUploadURL="/editor/filemanager/upload/simpleuploader?Type=File"
								flashUploadURL="/editor/filemanager/upload/simpleuploader?Type=Flash">
							</fck:editor>
    
    </td>
    </tr>
    
    
    <tr>
              <td colspan="4" class="mtdtitle1">
              <input type="button" value="提交" class="tbutton" onclick="doedit()"/>
              <input type="reset" value="重置" class="tbutton"/>
              
              </td>
              </tr>
    </table>
    </nested:nest>
  </div>
</html:form>

</body>
</html>
